/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rule;

/**
 *
 * @author Daniel Gribel
 */
public class AtLeastOneUpperCaseChar extends Clause {

    public AtLeastOneUpperCaseChar(String p) {
        super(p);
        super.setLog("5 points for at least one upper case char");
    }
    
    @Override
    public boolean checkConditions() {
        for (char a : getPass().toCharArray()) {
            if (Character.isLetter(a) && Character.isUpperCase(a)) {
                punctuate(5);
                return true;
            }
        }
        return false;
    }

    @Override
    public String outputMessage() {
        return getLog();
    }
    
    public int count() {
        int count = 0;
        
        for (char a : getPass().toCharArray()) {
            if (Character.isLetter(a) && Character.isUpperCase(a)) {
                count++;
            }
        }
        return count;
    }
    
}
